<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%><%@ include file="/include.inc.jsp"%>
<script type="text/javascript">

var setting = {
          view: {
              dblClickExpand: false
          },
          check: {
				enable: true
			},
          data: {
              simpleData: {
                  enable: true
              }
          },
          callback: {
				onClick: function(event, treeId, treeNode) { 
					event.preventDefault();
				}
			}	
      };
	  
      $(function(){
         privilege_tree_init();
       });
      function privilege_tree_init(){
    	   $.post("${path}/function/treeData?roleId=${roles.id}",function(data){
              $.fn.zTree.init($("#privilege_tree"), setting, data);
          },"json");
      }
      function sub(){
    	  var ids = [];
    	  var treeObj = $.fn.zTree.getZTreeObj("privilege_tree");
		  var nodes = treeObj.getCheckedNodes(true);
		  $.each(nodes,function(k,v){
			  ids.push(v.id);
		  });
		  $("#privilegeIds").val(ids);
		  $("#privilege_form").submit();
      }

</script>

<div class="bjui-pageContent">
<form method="post" action="${path }/role/setPrivilege" class="pageForm" data-toggle="validate">
	<input type="hidden" name="id" value="${roles.id}"/>
	<input type="hidden" name="privilegeIds" id="privilegeIds" />
	<div class="pageFormContent" data-layout-h="0">
          <div class="sugtitle">
             <span class="sugtitleicon"><span class="strong colorgorning2">当前操作提示：</span><span class="colorgorningage">正在为 [ ${roles.name } ] 设置权限</span></span>
         </div>
         
         <div class="ItemBlockBorder">
          <div class="ItemBlock">
            <div class="formdiv">
				<div id="menuContent" class="menuContent" >
					<ul id="privilege_tree" class="ztree" style="margin-top: 0; margin-left: 120px"></ul>
				</div>
			</div>
          </div>
     	</div>
	</div>
	
	<div class="bjui-footBar" style="text-align: center;">
		<ul style="margin-left: 40%">
			<li style="float: left"><div class="buttonActive"><div class="buttonContent"><button onclick="sub()" class="btn-default" data-icon="cog" >确认设置</button></div></div></li>
			<li style="float: left"><div class="button"><div class="buttonContent"><button type="button" class="btn-close" data-icon="close" >取消设置</button></div></div></li>
		</ul>
	</div>

</form>

</div>
